home *** CD-ROM | disk | FTP | other *** search
/ Speccy ClassiX 1998 / Speccy ClassiX 98.iso / amiga_system / the_aminet / comm / tcp / slipcall30b1.lha / SLIPCall30 / SLIPCall < prev    next >
Text File  |  1995-09-17  |  37KB  |  1,095 lines

  1. /* SLIPCall 3.0 beta 1                             */
  2. /*                                                 */
  3. /* Av Thomas Egrelius (thomas@fotoslide.bmc.uu.se) */
  4. /*                                                 */
  5.  
  6. if ~show('L', "rexxsupport.library") then
  7.     if ~addlib('rexxsupport.library', 0, -30, 0) then exit 41
  8. if ~show('L', "rexxserdev.library") then
  9.     if ~addlib('rexxserdev.library', 0, -30, 5) then exit 42
  10.  
  11. options results
  12. /*signal on error*/ /* Funkar inte med MBWatch */
  13. signal on halt
  14. signal on break_c
  15. signal on break_d
  16.  
  17. prefsfile = 'S:SLIPCall.config'
  18. qual1 = 'ctrl '
  19. qual2 = ''
  20. qual3 = ''
  21. key = 'f1'
  22. action = ''
  23. poll = 0
  24. win = 1
  25.  
  26. if arg() > 0 then do
  27.     do x = 1 to words(arg(1))
  28.         if upper(left(word(arg(1),x),2)) = '-C' then prefsfile = right(word(arg(1),x),wordlength(arg(1),x)-2)
  29.         if upper(left(word(arg(1),x),3)) = '-Q1' then qual1 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  30.         if upper(left(word(arg(1),x),3)) = '-Q2' then qual2 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  31.         if upper(left(word(arg(1),x),3)) = '-Q3' then qual3 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  32.         if upper(left(word(arg(1),x),2)) = '-K' then key = right(word(arg(1),x),wordlength(arg(1),x)-2)
  33.         if upper(left(word(arg(1),x),2)) = '-A' then action = upper(right(word(arg(1),x),wordlength(arg(1),x)-2))
  34.         if upper(left(word(arg(1),x),2)) = '-P' then poll = 1
  35.         if upper(left(word(arg(1),x),2)) = '-W' then win = 0
  36.     end
  37. end
  38.  
  39. if action ~= 'RING' & action ~= '┼TERUPPTA' & action ~= '' then do
  40.     say 'Felaktig argumentangivelse: -A'action
  41.     exit
  42. end
  43.  
  44. version = '$VER:SLIPCall 3.0b1 (16.9.95)'
  45. cr = '0d'x
  46.  
  47. /**************************************
  48.  ****   Definitioner av f÷nstren   ****
  49.  **************************************/
  50.  
  51. 'zInterface SLIPCall Hotkey="'qual1||qual2||qual3||key'" PersistFile="'prefsfile'"'
  52.     'zImage Magnify Width=11 Height=9 Depth=1 Data="3E006300C180C180C18063003EC000E00060"'
  53.     'zImage Folder  Width=11 Height=9 Depth=1 Data="7800840087E0F8208020802080208020FFE0"'
  54.  
  55. /*** Huvudf÷nster ***/
  56.  
  57.     'zWindow WMain Label "SLIPCall 3.0b1: Direktval = <'qual1||qual2||qual3||key'>" Open Centered CloseEvent ChildMaxWidth'
  58.         'zMenu Arkiv'
  59.             'zObject Button MAbout Label "&Om..." Cause "zDoMethod WAbout Open"'
  60.             'zObject Line'
  61.             'zObject Button MHide Label "&G÷m" Cause "zDoMethod SLIPCall Deactivate"'
  62.             'zObject Button MQuit Label "&Quit" SelectEvent'
  63.         'zEndMenu'
  64.         'zMenu Hantering'
  65.             'zObject Button MRing Label "&Ring" SelectEvent"'
  66.             'zObject Button MResume Label "&┼teruppta" SelectEvent'
  67.             'zObject Button MAvsluta Label "&LΣgg pσ" SelectEvent'
  68.         'zEndMenu'
  69.         'zMenu InstΣllningar'
  70.             'zObject Button MPrefs Label "&─ndra..." SelectEvent'
  71.         'zEndMenu'
  72.  
  73.         'zGroup Horizontal'
  74.             'zGroup Vertical'
  75.                 'zObject TextDisplay IP NumColumns 40 Label "IP:"'
  76.                 'zObject TextDisplay HostName Numcolumns 40 Label "Namn:"'
  77.                 'zObject TextDisplay Status Label "Status:" NumColumns 40 Value "Offline"'
  78.             'zEndGroup'
  79.             'zObject Line'
  80.             'zGroup Vertical ChildMaxWidth'
  81.                 'zObject Button BRing Label "&Ring" SelectEvent'
  82.                 'zObject Button BResume Label "&┼teruppta" SelectEvent'
  83.                 'zObject Button BAvsluta Label "&LΣgg pσ" SelectEvent'
  84.             'zEndGroup'
  85.         'zEndGroup'
  86.         'zObject Line'
  87.         'zGroup Horizontal'
  88.             'zObject Button BHide Label "&G÷m" Cause "zDoMethod SLIPCall Deactivate"'
  89.             'zObject Button BPrefs Label "&InstΣllningar..." SelectEvent'
  90.             'zObject Button BAbout Label "&Om..." Cause "zDoMethod WAbout Open"'
  91.             'zObject Button BQuit Label "&Avsluta" SelectEvent'
  92.         'zEndGroup'
  93.     'zEndWindow'
  94.  
  95. /*** Aboutrequester ***/
  96.  
  97.     'zWindow WAbout Label "Om SLIPCall..." NoClose Blocking Justification Center Alignment Center'
  98.         'zGroup Horizontal'
  99.             'zObject StdI Image Which=Information'
  100.             'zObject Line'
  101.             'zGroup Vertical ChildMaxWidth'
  102.                 'zObject TextDisplay A1 NoBorder Value "SLIPCall 3.0 beta 1 (1995-09-16)"'
  103.                 'zObject TextDisplay A2 NoBorder Value "Copyright ⌐1995 Thomas Egrelius"'
  104.                 'zObject TextDisplay A3 NoBorder Value "email: egge@canit.se"'
  105.             'zEndGroup'
  106.         'zEndGroup'
  107.         'zObject Line'
  108.         'zObject Button AOK Label "   &OK   " Cause "zDoMethod WAbout Close"'
  109.     'zEndWindow'
  110.  
  111. /*** Varningsf÷nster ***/
  112.  
  113.     'zWindow WError Label "SLIPCall Meddelande" NoClose Blocking Justification Center Alignment Center'
  114.         'zGroup Horizontal'
  115.             'zObject StdI Image Which=Exclamation'
  116.             'zObject Line'
  117.             'zGroup Vertical ChildMaxWidth'
  118.                 'zObject TextDisplay E1 NoBorder Value "Felaktigt vΣrde angivet!"'
  119.                 'zObject TextDisplay E2 NoBorder Value ""'
  120.                 'zObject TextDisplay E3 NoBorder Value ""'
  121.             'zEndGroup'
  122.         'zEndGroup'
  123.         'zObject Line'
  124.         'zObject Button EOK Label "   &OK   " Cause "zDoMethod WError Close"'
  125.     'zEndWindow'
  126.  
  127. /*** NoAmitcp f÷nster ***/
  128.  
  129.     'zWindow WFault Label "SLIPCall Meddelande" NoClose Blocking Justification Center Alignment Center'
  130.         'zGroup Horizontal'
  131.             'zObject StdI Image Which=Stop'
  132.             'zObject Line'
  133.             'zGroup Vertical ChildMaxWidth'
  134.                 'zObject TextDisplay F1 NoBorder Value "Kan ej hitta AmiTCP!"'
  135.                 'zObject TextDisplay F2 NoBorder Value "Avslutar..."'
  136.             'zEndGroup'
  137.         'zEndGroup'
  138.         'zObject Line'
  139.         'zObject Button EOK Label "&Avsluta" SelectEvent'
  140.     'zEndWindow'
  141.  
  142. /*** Betainformation ***/
  143.  
  144.     'zWindow WBeta Label "SLIPCall Meddelande" NoClose Blocking Justification Center Alignment Center'
  145.         'zGroup Horizontal'
  146.             'zObject StdI Image Which=Information'
  147.             'zObject Line'
  148.             'zGroup Vertical ChildMaxWidth'
  149.                 'zObject TextDisplay E1 NoBorder Value "Denna funktion Σr ej implementerad Σnnu."'
  150.             'zEndGroup'
  151.         'zEndGroup'
  152.         'zObject Line'
  153.         'zObject Button BOK Label "   &OK   " Cause "zDoMethod WBeta Close"'
  154.     'zEndWindow'
  155.  
  156. /***  InstΣllningar ***/
  157.  
  158.     'zWindow WPrefs Label "InstΣllningar" NoClose Blocking ChildMaxWidth'
  159.         'zGroup Horizontal'
  160.             'zGroup Vertical'
  161.                 'zGroup Horizontal ChildMaxHeight'
  162.                     'zObject TextEntry PLogPath Persist Label "S÷kvΣg f÷r logfil:" MaxChars 100 NumColumns 32 Value "S:"'
  163.                     'zObject ButtonG PLogPathG Glyph=Folder UpEvent'
  164.                 'zEndGroup'
  165.                 'zObject TextEntry PPollcommand Persist Label "Pollningskommando:" MaxChars 64 NumColumns 32'
  166.                 'zObject TextEntry PUsername Persist Label "AmiTCP anvΣndare:" MaxChars 20 NumColumns 32 Value "<anvΣndarnamn>"'
  167.                 'zObject TextEntry PRetries Persist Label "Antal f÷rs÷k:" MaxChars 3 NumColumns 32 Value "10" ChangeEvent'
  168.                 'zGroup Horizontal'
  169.                     'zObject Button PClock Label "&Klocka" SelectEvent'
  170.                     'zObject TextEntry PClocktext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "Visas"'
  171.                 'zEndGroup'
  172.             'zEndGroup'
  173.             'zObject Line'
  174.             'zGroup Vertical ChildMaxWidth'
  175.                 'zObject Button PHost Label "L&everant÷r" Cause "zDoMethod WPrefsHost Open"'
  176.                 'zObject Button PModem Label "&Modem" Cause "zDoMethod WPrefsModem Open"'
  177.                 'zObject Button PScript Label "S&cript" Cause "zDoMethod WPrefsScript Open"'
  178.             'zEndGroup'
  179.         'zEndGroup'
  180.         'zObject Line'
  181.         'zGroup Horizontal'
  182.             'zObject Button PSave Label "&Spara" SelectEvent'
  183.             'zObject Button PSaveAs Label "Spara s&om..." SelectEvent'
  184.             'zObject Button PLoad Label "&Ladda..." SelectEvent'
  185.             'zObject Button PCancel Label "A&vbryt" SelectEvent'
  186.         'zEndGroup'
  187.     'zEndWindow'
  188.  
  189. /*** InstΣllningar - Leverant÷r ***/
  190.  
  191.     'zWindow WPrefsHost Label "Leverant÷rsinstΣllningar" NoClose Blocking ChildMaxWidth'
  192.         'zObject TextEntry PHostName Persist Label "&Leverant÷r:" MaxChars 64 NumColumns 20'
  193.         'zObject TextEntry PPhone Persist Label "&Telenummer:" MaxChars 20 NumColumns 20'
  194.         'zObject TextEntry PDomain Persist Label "&Hostnamn:" MaxChars 32 NumColumns 20 Value ".se"'
  195.         'zObject TextEntry PHostIP Persist Label "Host&IP:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  196.         'zObject TextEntry PNameserver Persist Label "&Nameserver:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  197.         'zObject TextEntry PGateway Persist Label "&Gateway:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  198.         'zObject TextEntry PStatic Persist Label "Statisk IP:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  199.         'zObject TextEntry PMTU Persist Label "&MTU:" MaxChars 4 NumColumns 20 Value "1500"'
  200.         'zObject Line'
  201.         'zGroup Horizontal'
  202.             'zObject Button PProtocol Label "&Protokoll" SelectEvent'
  203.             'zObject TextEntry PPrototext Persist Value "CSLIP" NumColumns 10 ChangeEvent'
  204.             'zObject Button PDynamic Label "A&ddresseringstyp" SelectEvent'
  205.             'zObject TextEntry PDyntext Persist Value "Dynamisk" NumColumns 10 ChangeEvent'
  206.         'zEndGroup'
  207.         'zObject Line'
  208.         'zGroup Horizontal ChildMaxWidth'
  209.             'zObject Button HostOK Label "&Spara" SelectEvent'
  210.             'zObject Button HostCancel Label "&Avbryt" SelectEvent'
  211.         'zEndGroup'
  212.     'zEndWindow'
  213.  
  214. /*** InstΣllningar - Modem ***/
  215.  
  216.     'zWindow WPrefsModem Label "ModeminstΣllningar" NoClose Blocking ChildMaxWidth'
  217.         'zObject TextEntry PInit Persist Label "Modem&Init:" MaxChars 64 NumColumns 20 Value "AT&F0&D0"'
  218.         'zObject TextEntry PReset Persist Label "Modem&Reset:" MaxChars 64 NumColumns 20 Value "ATZ"'
  219.         'zObject Line'
  220.         'zObject TextEntry PDevice Persist Label "&Drivrutin:" MaxChars 64 NumColumns 20 Value "serial.device"'
  221.         'zGroup Horizontal ChildMaxWidth Alignment Center'
  222.             'zGroup Vertical NoMargY ChildMaxWidth'
  223.                 'zObject Button PUnit Label "&Enhet" SelectEvent'
  224.                 'zObject TextEntry PUnittext Persist MaxChars 1 NumColumns 10 ChangeEvent Value "0"'
  225.                 'zObject Button PSpeed Label "&Hastighet" SelectEvent'
  226.                 'zObject TextEntry PSpeedtext Persist MaxChars 6 NumColumns 10 ChangeEvent Value "38400"'
  227.                 'zObject Button PHShake Label "Hands&kakning" SelectEvent'
  228.                 'zObject TextEntry PHShaketext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "RTS/CTS"'
  229.             'zEndGroup'
  230.             'zObject Line'
  231.             'zGroup Vertical Align NoMargy ChildMaxWidth'
  232.                 'zObject Button PBits Label "Data&bitar" SelectEvent'
  233.                 'zObject TextEntry PBitstext Persist MaxChars 1 NumColumns 10 ChangeEvent Value "8"'
  234.                 'zObject Button PParity Label "&Paritet" SelectEvent'
  235.                 'zObject TextEntry PParitytext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "Ingen" '
  236.                 'zObject Button PStops Label "Stopbi&tar" SelectEvent'
  237.                 'zObject TextEntry PStopstext Persist MaxChars 1 NumColumns 1 ChangeEvent Value "1"'
  238.             'zEndGroup'
  239.         'zEndGroup'
  240.         'zObject Line'
  241.         'zGroup Horizontal ChildMaxWidth'
  242.             'zObject Button ModemOK Label "&Spara" SelectEvent'
  243.             'zObject Button ModemCancel Label "&Avbryt" SelectEvent'
  244.         'zEndGroup'
  245.     'zEndWindow'
  246.  
  247. /*** InstΣllningar - Script ***/
  248.  
  249.     'zWindow WPrefsScript Label "Inloggningsscript" Blocking ChildMaxWidth'
  250.         'zGroup Horizontal ChildMaxHeight'
  251.             'zObject Button SB1 Label "V/S" SelectEvent'
  252.             'zObject TextEntry ST1 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "VΣnta pσ"'
  253.             'zObject TextEntry S1 Persist MaxChars 64 NumColumns 30'
  254.         'zEndGroup'
  255.         'zGroup Horizontal ChildMaxHeight'
  256.             'zObject Button SB2 Label "V/S" SelectEvent'
  257.             'zObject TextEntry ST2 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Skicka"'
  258.             'zObject TextEntry S2 Persist MaxChars 64 NumColumns 30'
  259.         'zEndGroup'
  260.         'zGroup Horizontal ChildMaxHeight'
  261.             'zObject Button SB3 Label "V/S" SelectEvent'
  262.             'zObject TextEntry ST3 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "VΣnta pσ"'
  263.             'zObject TextEntry S3 Persist MaxChars 64 NumColumns 30'
  264.         'zEndGroup'
  265.         'zGroup Horizontal ChildMaxHeight'
  266.             'zObject Button SB4 Label "V/S" SelectEvent'
  267.             'zObject TextEntry ST4 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Skicka"'
  268.             'zObject TextEntry S4 Persist MaxChars 64 NumColumns 30'
  269.         'zEndGroup'
  270.         'zGroup Horizontal ChildMaxHeight'
  271.             'zObject Button SB5 Label "V/S" SelectEvent'
  272.             'zObject TextEntry ST5 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "VΣnta pσ"'
  273.             'zObject TextEntry S5 Persist MaxChars 64 NumColumns 30'
  274.         'zEndGroup'
  275.         'zGroup Horizontal ChildMaxHeight'
  276.             'zObject Button SB6 Label "V/S" SelectEvent'
  277.             'zObject TextEntry ST6 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Skicka"'
  278.             'zObject TextEntry S6 Persist MaxChars 64 NumColumns 30'
  279.         'zEndGroup'
  280.         'zGroup Horizontal ChildMaxHeight'
  281.             'zObject Button SB7 Label "V/S" SelectEvent'
  282.             'zObject TextEntry ST7 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "VΣnta pσ"'
  283.             'zObject TextEntry S7 Persist MaxChars 64 NumColumns 30'
  284.         'zEndGroup'
  285.         'zGroup Horizontal ChildMaxHeight'
  286.             'zObject Button SB8 Label "V/S" SelectEvent'
  287.             'zObject TextEntry ST8 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Skicka"'
  288.             'zObject TextEntry S8 Persist MaxChars 64 NumColumns 30'
  289.         'zEndGroup'
  290.         'zGroup Horizontal ChildMaxHeight'
  291.             'zObject Button SB9 Label "V/S" SelectEvent'
  292.             'zObject TextEntry ST9 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "VΣnta pσ"'
  293.             'zObject TextEntry S9 Persist MaxChars 64 NumColumns 30'
  294.         'zEndGroup'
  295.         'zGroup Horizontal ChildMaxHeight'
  296.             'zObject Button SB10 Label "V/S" SelectEvent'
  297.             'zObject TextEntry ST10 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Skicka"'
  298.             'zObject TextEntry S10 Persist MaxChars 64 NumColumns 30'
  299.         'zEndGroup'
  300.         'zObject Line'
  301.         'zGroup Horizontal ChildMaxWidth'
  302.             'zObject Button ScriptOK Label "&Spara" SelectEvent'
  303.             'zObject Button ScriptCancel Label "&Avbryt" SelectEvent'
  304.         'zEndGroup'
  305.     'zEndWindow'
  306. 'zEndInterface'
  307.  
  308. /*** Starta upp... ***/
  309.  
  310. if ~exists('AmiTCP:') then do
  311.     'zDoMethod WFault Open'
  312.     call run()
  313. end
  314.  
  315. flags.call = 0
  316. flags.serclosed = 1
  317. flags.tcponline = 0
  318.  
  319. if win then 'zDoMethod SLIPCall Activate'
  320.  
  321. call Initialize()
  322.  
  323. if poll then do
  324.     prefs.clock = 0
  325.     call MRing_Select()
  326.     address command prefs.pollcommand
  327.     call MQuit_Select()
  328. end
  329.  
  330. if action = 'RING' then call MRing_Select()
  331. if action = '┼TERUPPTA' then call MResume_Select()
  332.  
  333. run:
  334. do forever
  335.     'zWaitForEvent stem.'
  336.     interpret "zRC="RESULT"()"
  337. end
  338.  
  339. /*** Funktioner som hanterar GUI events ***/
  340.  
  341. /*** Avsluta ***/
  342.  
  343. halt:
  344. break_c:
  345. MQuit_Select:
  346. BQuit_Select:
  347. WMain_Close:
  348. SLIPCall_Quit:
  349.     call MAvsluta_Select()
  350.     exit
  351.  
  352. break_d:
  353.     call MAvsluta_Select()
  354.     return 0
  355.  
  356. EOK_Select:
  357.     'zDoMethod WFault Close'
  358.     exit
  359.  
  360. Error:
  361.     call MAvsluta_Select()
  362.     if rc=20 then do
  363.         say "Mσste k÷ras med zrx!"
  364.         exit
  365.     end
  366.     say "Fel" RC "pσ rad" SIGL " (errnum="zErrNum")"
  367.     exit
  368.  
  369. BPrefs_Select:
  370. MPrefs_Select:
  371.     if connected ~= 1 then 'zDoMethod WPrefs Open'
  372.     return 0
  373.  
  374. /*** Ring ***/
  375.  
  376. BRing_Select:
  377. MRing_Select:
  378.     flags.call = 1
  379.     dh = SerOpen(prefs.device, prefs.unit)
  380.     if (dh == 0) then do
  381.         'zSetAttr E1 Value "Allvarligt fel!"'
  382.         'zSetAttr E2 Value ""'
  383.         'zSetAttr E3 Value "Kan inte ÷ppna 'prefs.device'"'
  384.         'zDoMethod WError Open'
  385.         return 0
  386.     end
  387.  
  388.     flags.serclosed = 0
  389.     check     = SerClear(dh)
  390.     check     = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits, prefs.handshake, 250000, 4096)
  391.     buffer    = AllocMem(4096)
  392.     junk      = c2d(buffer)
  393.     check     = 0
  394.     connected = 0
  395.  
  396.     SerWrite(dh, prefs.modeminit, length(prefs.modeminit))
  397.     do x = 1 to prefs.retries
  398.         'zSetAttr Status Value "Ringer upp '||prefs.hostname||', f÷rs÷k '||x||' av '||prefs.retries||'."'
  399.         do forever
  400.             Delay(100)
  401.             if (check == 0) then do
  402.                 result = SerWrite(dh, 'ATDT'||prefs.hostphone||cr, length('ATDT'||prefs.hostphone||cr))
  403.                 check = 1
  404.                 totalstr = ''
  405.             end
  406.             status = SerQuery(dh)
  407.             parse upper var status valid bytes_read .
  408.             rcvdstrg = SerRead(dh, junk, bytes_read)
  409.             totalstr = totalstr||rcvdstrg
  410.             check = modem_query(totalstr)
  411.             check2 = 0
  412.             if (check == 100) then leave
  413.             if (check == 101) then do; check = 0; check2 = 1; 'zSetAttr Status Value "Upptaget..."'; Delay(100); end
  414.             if (check == 102) then do; check = 0; check2 = 1; 'zSetAttr Status Value "Ingen bΣrvσg..."'; Delay(100); end
  415.             if (check == 103) then do; check = 0; check2 = 1; 'zSetAttr Status Value "Inget svar..."'; Delay(100); end
  416.             if check2 then leave
  417.         end
  418.         if (check == 100) then leave
  419.     end
  420.  
  421.     if check ~= 100 then do; call CloseSer(); 'zSetAttr Status Value "Offline"'; return 0; end
  422.     connected = 1
  423.     parse var totalstr .'CONNECT ' linespeed+5 +2 totalstr
  424.     if prefs.clock then do
  425.         if ~show('p', 'MBWATCH.01') then address command 'run >NIL: <NIL: mbwatch start logtime 10'
  426.         else do
  427.             address mbwatch.01 reset
  428.             address mbwatch.01 start
  429.         end
  430.     end
  431.     'zSetAttr Status Value "Uppkopplad mot 'prefs.hostname' i 'linespeed' bps."'
  432.     if ~exists(prefs.logpath) then do
  433.         call Open(logfile, prefs.logpath, 'W')
  434.         writeln(logfile, '')
  435.         call Close(logfile)
  436.     end
  437.     if Open(logfile, prefs.logpath, 'A') then do
  438.         writeln(logfile, '')
  439.         writeln(logfile, date()||' '||time()||'  Uppkopplad mot '||prefs.hostname||' pσ '||prefs.hostphone)
  440.         call Close(logfile)
  441.     end
  442.  
  443.     call login()
  444.  
  445.     return 0
  446.  
  447. /*** ┼teruppta ***/
  448.  
  449. BResume_Select:
  450. MResume_Select:
  451.     if exists('ENVARC:ip') then do
  452.         slipip = 0
  453.         if Open(file, 'ENVARC:ip', 'R') then do
  454.             slipip = readln(file)
  455.             slipip = slipip||'  '
  456.             call Close(file)
  457.         end
  458.         if prefs.clock then do
  459.             if ~show('P', 'MBWATCH.01') then address command 'run >NIL: <NIL: mbwatch logtime 10'
  460.             address 'MBWATCH.01' 'START'
  461.         end
  462.         'zSetAttr Status Value "F÷rs÷ker σteruppta uppkoppling med 'prefs.hostname'..."'
  463.         address command 'copy ENVARC:ip ENV:ip'
  464.         if ~exists('ENV:Sana2') then address command 'makedir ENV:Sana2'
  465.         address command 'echo >ENV:Sana2/rhslip0.config "'prefs.device prefs.unit prefs.speed '$ip MTU='prefs.mtu' 7WIRE"'
  466.         if ip ~= 0 then 'zSetAttr IP Value "'||left(slipip,length(slipip)-2)'"'
  467.         call startnet()
  468.         connected = 1
  469.     end
  470.     else do
  471.         'zSetAttr Status Value "Kunde inte σteruppta f÷rlorad uppkoppling!"'
  472.         Delay(300)
  473.         flags.call = 1
  474.         connected = 1
  475.         call hangup()
  476.     end
  477.     return 0
  478.  
  479. /*** LΣgg pσ ***/
  480.  
  481. BAvsluta_Select:
  482. MAvsluta_Select:
  483.     if connected = 1 then do
  484.         'zSetAttr Status Value "Avslutar uppkopplingen..."'
  485.         if flags.tcponline then do
  486.             address command 'AmiTCP:bin/offline 'prefs.slipdevice
  487.             flags.tcponline = 0
  488.         end
  489.         Delay(100)
  490.         if flags.serclosed then do
  491.             dh = SerOpen(prefs.device, prefs.unit)
  492.             flags.serclosed = 0
  493.             check = SerClear(dh)
  494.             check = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits)
  495.         end
  496.         call hangup()
  497.         if show('P', 'AMITCP') then address 'AMITCP' 'KILL'
  498.  
  499.         'zSetAttr IP Value " "'
  500.         'zSetAttr HostName Value " "'
  501.         'zSetAttr Status Value "Offline"'
  502.     end
  503.     return 0
  504.  
  505. /*** InstΣllningar - AnvΣnd ***/
  506.  
  507. PSave_Select:
  508.     'zDoMethod WPrefs Save'
  509.     'zDoMethod WPrefs Close'
  510.     call Initialize()
  511.     return 0
  512.  
  513. /*** InstΣllningar - Spara som... ***/
  514.  
  515. PSaveAs_Select:
  516.     'zDoMethod WBeta Open'
  517.     return 0
  518.  
  519. /*** InstΣllningar - Ladda ***/
  520.  
  521. PLoad_Select:
  522.     'zDoMethod WBeta Open'
  523.     return 0
  524.  
  525. /*** InstΣllningar - Avbryt ***/
  526.  
  527. PCancel_Select:
  528.     'zDoMethod WPrefs Restore'
  529.     'zDoMethod WPrefs Close'
  530.     call initialize()
  531.     return 0
  532.  
  533. PProtocol_Select:
  534.  
  535.     'zGetAttr PPrototext Value'
  536.     if result = "CSLIP" then 'zSetAttr PPrototext Value "SLIP"'
  537.     else 'zSetAttr PPrototext Value "CSLIP"'
  538.     return 0
  539.  
  540. PPrototext_Change:
  541.     'zGetAttr PPrototext Value'
  542.     value = result
  543.     if upper(result) ~= "CSLIP" & upper(result) ~= "SLIP" then do
  544.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  545.         'zSetAttr E2 Value ""'
  546.         'zSetAttr E3 Value "Protokoll: 'value'"'
  547.         'zDoMethod WError Open'
  548.         'zSetAttr PPrototext Value "CSLIP"'
  549.     end
  550.     return 0
  551.  
  552. PDynamic_Select:
  553.     'zGetAttr PDyntext Value'
  554.     if result = "Dynamisk" then 'zSetAttr PDyntext Value "Statisk"'
  555.     else 'zSetAttr PDyntext Value "Dynamisk"'
  556.     return 0
  557.  
  558. PDyntext_Change:
  559.     'zGetAttr PDyntext Value'
  560.     value = result
  561.     if upper(result) ~= "DYNAMISK" & upper(result) ~= "STATISK" then do
  562.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  563.         'zSetAttr E2 Value ""'
  564.         'zSetAttr E3 Value "Addresseringstyp: 'value'"'
  565.         'zDoMethod WError Open'
  566.         'zSetAttr PDyntext Value "Dynamisk"'
  567.     end
  568.     return 0
  569.  
  570. PUnit_Select:
  571.     'zGetAttr PUnittext Value'
  572.     enhet = result + 1
  573.     if enhet > 9 then enhet = 0
  574.     'zSetAttr PUnittext Value "'||enhet||'"'
  575.     return 0
  576.  
  577. PUnittext_Change:
  578.     'zGetAttr PUnittext Value'
  579.     value = result
  580.     if result < "0" | result > "9" then do
  581.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  582.         'zSetAttr E2 Value ""'
  583.         'zSetAttr E3 Value "Enhet: 'value'"'
  584.         'zDoMethod WError Open'
  585.         'zSetAttr PUnittext Value "0"'
  586.     end
  587.     return 0
  588.  
  589. PSpeed_select:
  590.     'zGetAttr PSpeedtext Value'
  591.     hastighet = result
  592.     if hastighet = "115200" then hastighet = "1200"
  593.     if hastighet = "57600" then hastighet = "115200"
  594.     if hastighet = "38400" then hastighet = "57600"
  595.     if hastighet = "19200" then hastighet = "38400"
  596.     if hastighet = "14400" then hastighet = "19200"
  597.     if hastighet = "9600" then hastighet = "14400"
  598.     if hastighet = "2400" then hastighet = "9600"
  599.     if hastighet = "1200" then hastighet = "2400"
  600.     'zSetAttr PSpeedtext Value "'||hastighet||'"'
  601.     return 0
  602.  
  603. PSpeedtext_Change:
  604.     'zGetAttr PSpeedtext Value'
  605.     value = result
  606.     if result ~= "115200" & result ~= "57600" & result ~= "38400" & result ~= "19200" & result ~= "14400" & result ~= "9600" & result ~= "2400" then do
  607.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  608.         'zSetAttr E2 Value ""'
  609.         'zSetAttr E3 Value "Hastighet: 'value'"'
  610.         'zDoMethod WError Open'
  611.         'zSetAttr PSpeedtext Value "38400"'
  612.     end
  613.     return 0
  614.  
  615. PHShake_Select:
  616.     'zGetAttr PHShaketext Value'
  617.     handshake = result
  618.     if handshake = "RTS/CTS" then handshake = "XON/XOFF"
  619.     else handshake = "RTS/CTS"
  620.     'zSetAttr PHShaketext Value "'||handshake||'"'
  621.     return 0
  622.  
  623. PHShaketext_Change:
  624.     'zGetAttr PHShaketext Value'
  625.     value = result
  626.     if upper(result) ~= "RTS/CTS" & upper(result) ~= "XON/XOFF" then do
  627.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  628.         'zSetAttr E2 Value ""'
  629.         'zSetAttr E3 Value "Handskakning: 'value'"'
  630.         'zDoMethod WError Open'
  631.         'zSetAttr PHShaketext Value "RTS/CTS"'
  632.     end
  633.     return 0
  634.  
  635. PBits_Select:
  636.     'zGetAttr PBitstext Value'
  637.     bits = result +1
  638.     if bits > 8 then bits = 1
  639.     'zSetAttr PBitstext Value "'||bits||'"'
  640.     return 0
  641.  
  642. PBitstext_Change:
  643.     'zGetAttr PBitstext Value'
  644.     value = result
  645.     if result < "1" | result > "8" then do
  646.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  647.         'zSetAttr E2 Value ""'
  648.         'zSetAttr E3 Value "Databitar: 'value'"'
  649.         'zDoMethod WError Open'
  650.         'zSetAttr PBitstext Value "8"'
  651.     end
  652.     return 0
  653.  
  654. PParity_Select:
  655.     'zGetAttr PParitytext Value'
  656.     paritet = result
  657.     if paritet = "Space" then paritet = "X"
  658.     if paritet = "Mark" then paritet = "Space"
  659.     if paritet = "Udda" then paritet = "Mark"
  660.     if paritet = "JΣmn" then paritet = "Udda"
  661.     if paritet = "Ingen" then paritet = "JΣmn"
  662.     if paritet = "X" then paritet = "Ingen"
  663.     'zSetAttr PParitytext Value "'||paritet||'"'
  664.     return 0
  665.  
  666. PParitytext_Change:
  667.     'zGetAttr PParitytext Value'
  668.     value = result
  669.     if upper(result) ~= "SPACE" & upper(result) ~= "MARK" & upper(result) ~= "UDDA" & upper(result) ~= "J─MN" & upper(result) ~= "INGEN" then do
  670.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  671.         'zSetAttr E2 Value ""'
  672.         'zSetAttr E3 Value "Paritet: 'value'"'
  673.         'zDoMethod WError Open'
  674.         'zSetAttr PParitytext Value "Ingen"'
  675.     end
  676.     return 0
  677.  
  678. PStops_Select:
  679.     'zGetAttr PStopstext Value'
  680.     stopbits = result + 1
  681.     if stopbits > 2 then stopbits = 1
  682.     'zSetAttr PStopstext Value "'||stopbits||'"'
  683.     return 0
  684.  
  685. PStopstext_Change:
  686.     'zGetAttr PStopstext Value'
  687.     value = result
  688.     if result < "1" | result > "2" then do
  689.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  690.         'zSetAttr E2 Value ""'
  691.         'zSetAttr E3 Value "Stopbitar: 'value'"'
  692.         'zDoMethod WError Open'
  693.         'zSetAttr PStopstext Value "1"'
  694.     end
  695.     return 0
  696.  
  697. SB1_Select:
  698.     call ScriptChangeValue(ST1)
  699.     return 0
  700.  
  701. ST1_Change:
  702.     call ScriptCheckValue(ST1)
  703.     return 0
  704.  
  705. SB2_Select:
  706.     call ScriptChangeValue(ST2)
  707.     return 0
  708.  
  709. ST2_Change:
  710.     call ScriptCheckValue(ST2)
  711.     return 0
  712.  
  713. SB3_Select:
  714.     call ScriptChangeValue(ST3)
  715.     return 0
  716.  
  717. ST3_Change:
  718.     call ScriptCheckValue(ST3)
  719.     return 0
  720.  
  721. SB4_Select:
  722.     call ScriptChangeValue(ST4)
  723.     return 0
  724.  
  725. ST4_Change:
  726.     call ScriptCheckValue(ST4)
  727.     return 0
  728.  
  729. SB5_Select:
  730.     call ScriptChangeValue(ST5)
  731.     return 0
  732.  
  733. ST5_Change:
  734.     call ScriptCheckValue(ST5)
  735.     return 0
  736.  
  737. SB6_Select:
  738.     call ScriptChangeValue(ST6)
  739.     return 0
  740.  
  741. ST6_Change:
  742.     call ScriptCheckValue(ST6)
  743.     return 0
  744.  
  745. SB7_Select:
  746.     call ScriptChangeValue(ST7)
  747.     return 0
  748.  
  749. ST7_Change:
  750.     call ScriptCheckValue(ST7)
  751.     return 0
  752.  
  753. SB8_Select:
  754.     call ScriptChangeValue(ST8)
  755.     return 0
  756.  
  757. ST8_Change:
  758.     call ScriptCheckValue(ST8)
  759.     return 0
  760.  
  761. SB9_Select:
  762.     call ScriptChangeValue(ST9)
  763.     return 0
  764.  
  765. ST9_Change:
  766.     call ScriptCheckValue(ST9)
  767.     return 0
  768.  
  769. SB10_Select:
  770.     call ScriptChangeValue(ST10)
  771.     return 0
  772.  
  773. ST10_Change:
  774.     call ScriptCheckValue(ST10)
  775.     return 0
  776.  
  777. PRetries_Change:
  778.     'zGetAttr PRetries Value'
  779.     value = result
  780.     if ~datatype(value, 'N') then do
  781.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  782.         'zSetAttr E2 Value ""'
  783.         'zSetAttr E3 Value "Antal f÷rs÷k: 'value'"'
  784.         'zDoMethod WError Open'
  785.         'zSetAttr PRetries Value "20"'
  786.     end
  787.     return 0
  788.  
  789. PClock_Select:
  790.     'zGetAttr PClocktext Value'
  791.     if result = "Visas" then 'zSetAttr PClocktext Value "Visas Ej"'
  792.     else 'zSetAttr PClocktext Value "Visas"'
  793.     return 0
  794.  
  795. PClocktext_Change:
  796.     'zGetAttr PClocktext Value'
  797.     value = result
  798.     if upper(result) ~= "VISAS" & upper(result) ~= "VISAS EJ" then do
  799.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  800.         'zSetAttr E2 Value ""'
  801.         'zSetAttr E3 Value "Klocka: 'value'"'
  802.         'zDoMethod WError Open'
  803.         'zSetAttr PClocktext Value "Visas"'
  804.     end
  805.     return 0
  806.  
  807. PLogPathG_Change:
  808.     'zGetAttr PLogPath Value'
  809.     'zRequest Directory Label "VΣlj s÷kvΣg f÷r logfilen:" Value "'result'"'
  810.     'zSetAttr PLogPath Value "'||result||'"'
  811.     return 0
  812.  
  813. HostOK_Select:
  814.     'zDoMethod WPrefsHost Save'
  815.     'zDoMethod WPrefsHost Close'
  816.     return 0
  817.  
  818. HostCancel_Select:
  819.     'zDoMethod WPrefsHost Restore'
  820.     'zDoMethod WPrefsHost Close'
  821.     return 0
  822.  
  823. ModemOK_Select:
  824.     'zDoMethod WPrefsModem Save'
  825.     'zDoMethod WPrefsModem Close'
  826.     return 0
  827.  
  828. ModemCancel_Select:
  829.     'zDoMethod WPrefsModem Restore'
  830.     'zDoMethod WPrefsModem Close'
  831.     return 0
  832.  
  833. ScriptOK_Select:
  834.     'zDoMethod WPrefsScript Save'
  835.     'zDoMethod WPrefsScript Close'
  836.     return 0
  837.  
  838. ScriptCancel_Select:
  839.     'zDoMethod WPrefsScript Restore'
  840.     'zDoMethod WPrefsScript Close'
  841.     return 0
  842.  
  843.  
  844.  
  845.  
  846.  
  847. ScriptChangeValue:
  848.     parse arg gadget
  849.  
  850.     'zGetAttr 'gadget' Value'
  851.     if result = "VΣnta pσ" then 'zSetAttr 'gadget' Value "Skicka"'
  852.     else 'zSetAttr 'gadget' Value "VΣnta pσ"'
  853.     return 0
  854.  
  855. ScriptCheckValue:
  856.     parse arg gadget
  857.  
  858.     'zGetAttr 'gadget' Value'
  859.     value = result
  860.     if upper(result) ~= "V─NTA P┼" & upper(result) ~= "SKICKA" then do
  861.         'zSetAttr E1 Value "Felaktigt vΣrde angivet!"'
  862.         'zSetAttr E2 Value ""'
  863.         'zSetAttr E3 Value "Script: 'value'"'
  864.         'zDoMethod WError Open'
  865.         'zSetAttr 'gadget' Value "VΣnta pσ"'
  866.     end
  867.     return 0
  868.  
  869.  
  870. Initialize:
  871.     'zSetAttr Status Value "Initialiserar SLIPCall..."'
  872.     'zGetAttr PLogPath Value'
  873.     prefs.logpath = result'SLIPCalls.log'
  874.     'zGetAttr PPollcommand Value'
  875.     prefs.pollcommand = result
  876.     'zGetAttr PUsername Value'
  877.     prefs.username = result
  878.     'zGetAttr PClocktext Value'
  879.     if upper(result) = "VISAS" then prefs.clock = "1"
  880.     else prefs.clock = "0"
  881.     'zGetAttr PRetries Value'
  882.     prefs.retries = result
  883.     'zGetAttr PHostName Value'
  884.     prefs.hostname = result
  885.     'zGetAttr PPhone Value'
  886.     prefs.hostphone = result
  887.     'zGetAttr PDomain Value'
  888.     prefs.hostdomain = result
  889.     'zGetAttr PHostIP Value'
  890.     prefs.hostip = result
  891.     'zGetAttr PNameserver Value'
  892.     prefs.nameserver = result
  893.     'zGetAttr PGateway Value'
  894.     prefs.gateway = result
  895.     'zGetAttr PStatic Value'
  896.     prefs.statisk = result
  897.     'zGetAttr PMTU Value'
  898.     prefs.mtu = result
  899.     'zGetAttr PPrototext Value'
  900.     prefs.protokoll = upper(result)
  901.     prefs.slipdevice = 'rhslip.device 0'
  902.     prefs.sanadriver = 'slip0'
  903.     if prefs.protokoll = 'CSLIP' then do
  904.         prefs.slipdevice = 'rhcslip.device 0'
  905.         prefs.sanadriver = 'cslip0'
  906.     end
  907.     'zgetAttr PDyntext Value'
  908.     prefs.adressering = upper(result)
  909.     'zGetAttr PInit Value'
  910.     prefs.modeminit = upper(result)||cr
  911.     'zGetAttr PReset Value'
  912.     prefs.modemreset = upper(result)||cr
  913.     'zGetAttr PDevice Value'
  914.     prefs.device = result
  915.     'zGetAttr PUnittext Value'
  916.     prefs.unit = result
  917.     'zGetAttr PSpeedtext Value'
  918.     prefs.speed = result
  919.     'zGetAttr PHShaketext Value'
  920.     if upper(result) = "RTS/CTS" then prefs.handshake = "0"
  921.     else prefs.handshake = "1"
  922.     'zGetAttr PBitstext Value'
  923.     prefs.databits = result
  924.     'zGetAttr PParitytext Value'
  925.     prefs.paritet = "N"
  926.     if upper(result) = "J─MN" then prefs.paritet = "E"
  927.     if upper(result) = "UDDA" then prefs.paritet = "O"
  928.     if upper(result) = "MARK" then prefs.paritet = "M"
  929.     if upper(result) = "SPACE" then prefs.paritet = "S"
  930.     'zGetAttr PStopstext Value'
  931.     prefs.stopbits = result
  932.     do x = 1 to 10
  933.         'zGetAttr ST'||x||' Value'
  934.         if upper(result) = "V─NTA P┼" then event.x = "WAIT"
  935.         else event.x = "SEND"
  936.         'zGetAttr S'||x||' Value'
  937.         if result ~= 'RESULT' then string.x = result
  938.         else string.x = ''
  939.     end
  940.  
  941.     /*** Konfigurera AmiTCP ***/
  942.  
  943.     if ~exists('AmiTCP:db/resolv.conf.bkup') then do
  944.         if exists('AmiTCP:db/resolv.conf') then address command 'rename AmiTCP:db/resolv.conf as AmiTCP:db/resolv.conf.bkup'
  945.     end
  946.     address command 'echo >AmiTCP:db/resolv.conf "DOMAIN 'prefs.hostdomain'"'
  947.     address command 'echo >>AmiTCP:db/resolv.conf "NAMESERVER 'prefs.nameserver'"'
  948.  
  949.     'zSetAttr Status Value "Offline"'
  950.  
  951.     return 0
  952.  
  953. login:
  954.     SerWrite(dh, cr, length(cr))
  955.     do x=1 to 10
  956.         if string.x ~= '' then do
  957.             if event.x = "WAIT" then waitresult = wait_str(string.x)
  958.             if event.x = "SEND" then SerWrite(dh, string.x||cr, length(string.x||cr))
  959.         end
  960.         else leave
  961.         if waitresult = 10 then do
  962.             call FreeMem(buffer, 4096)
  963.             return 0
  964.         end
  965.     end
  966.     SerClose(dh)
  967.     flags.serclosed = 1
  968.  
  969.     laststring = x - 1
  970.     parse var rcvdstr . (string.laststring) ' ' a '.' b '.' c '.' d .
  971.     if prefs.adressering = "DYNAMISK" then slipip = a||'.'||b||'.'||c||'.'||d
  972.     else slipip = prefs.statisk||'  '
  973.     'zSetAttr IP Value "'||left(slipip, length(slipip)-2)||'   ('time()', 'date()')"'
  974.     address command 'echo >ENV:ip '||left(slipip, length(slipip)-2)
  975.     address command 'echo >ENVARC:ip '||left(slipip, length(slipip)-2)
  976.  
  977.     /*** Skapa ENV:Sana2/rhslip0.config ***/
  978.  
  979.     if ~exists('ENV:Sana2') then address command 'makedir ENV:Sana2'
  980.     address command 'echo >ENV:Sana2/rhslip0.config "'prefs.device prefs.unit prefs.speed '$ip MTU='prefs.mtu' 7WIRE"'
  981.  
  982.     call startnet()
  983.  
  984.     call FreeMem(buffer, 4096)
  985.     return 0
  986.  
  987. wait_str:
  988.   teststr = arg(1)
  989.   check = 0
  990.   timeout = 0
  991.   do until (check ~= 0)
  992.       status   = SerQuery(dh)
  993.       parse upper var status valid bytes_read .
  994.       rcvdstr  = SerRead(dh, junk, bytes_read)
  995.       totalstr = totalstr||rcvdstr
  996.       check    = pos(teststr,totalstr)
  997.       timeout = timeout + 1
  998.       if timeout = 100 then check = -1
  999.       Delay(20)
  1000.    end
  1001.    if check = -1 then do
  1002.       'zSetAttr Status Value "Timeout vid vΣntan pσ strΣng, lΣgger pσ."'
  1003.       Delay(100)
  1004.       call MAvsluta_Select()
  1005.       return 10
  1006.    end
  1007.    rcvdstr  = totalstr
  1008.    totalstr = ''
  1009. return 0
  1010.  
  1011. modem_query:
  1012.    teststr = arg(1)
  1013.    if (pos('CONNECT'   , teststr) ~= 0) then return 100
  1014.    if (pos('BUSY'      , teststr) ~= 0) then return 101
  1015.    if (pos('NO CARRIER', teststr) ~= 0) then return 102
  1016.    if (pos('NO ANSWER' , teststr) ~= 0) then return 103
  1017. return 200
  1018.  
  1019. CloseSer:
  1020.     call SerClose(dh)
  1021.     flags.serclosed = 1
  1022.     return 0
  1023.  
  1024. hangup:
  1025.     if flags.call then do
  1026.         if connected ~= 0 then do
  1027.             'zSetAttr Status Value "LΣgger pσ luren..."'
  1028.             if flags.serclosed then do
  1029.                 dh = SerOpen(prefs.device, prefs.unit)
  1030.                 if (dh == 0) then do
  1031.                     'zSetAttr E1 Value "Allvarligt fel!"'
  1032.                     'zSetAttr E2 Value ""'
  1033.                     'zSetAttr E3 Value "Kan inte ÷ppna 'prefs.device'"'
  1034.                     'zDoMethod WError Open'
  1035.                     return 0
  1036.                 end
  1037.  
  1038.                 check     = SerClear(dh)
  1039.                 check     = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits, prefs.handshake, 250000, 4096)
  1040.             end
  1041.             check = SerWrite(dh, '+++', 3)
  1042.             check = Delay(100)
  1043.             check = SerWrite(dh, 'ATH0'||cr, 5)
  1044.  
  1045.             if Open(logfile, prefs.logpath, 'A') then do
  1046.                 call writeln(logfile, date()||' '||time()||'  Uppkoppling avbruten')
  1047.                 call Close(logfile)
  1048.             end
  1049.             connected = 0
  1050.         end
  1051.         if prefs.clock then address 'MBWATCH.01' 'QUIT'
  1052.         Delay(300)
  1053.         SerWrite(dh, prefs.modemreset||cr, length(prefs.modemreset||cr))
  1054.         Delay(100)
  1055.         call SerClose(dh)
  1056.         flags.serclosed = 1
  1057.         flags.call = 0
  1058.     end
  1059.     return 0
  1060.  
  1061. GetHostName:
  1062.     name = '½OkΣnt╗'
  1063.     address command "AmiTCP:bin/hostname >T:actualname"
  1064.     if Open(file, 'T:actualname', 'R') then do
  1065.         name = readln(file)
  1066.         call Close(file)
  1067.     end
  1068.     'zSetAttr HostName Value "'name'"'
  1069.     return 0
  1070.  
  1071. startnet:
  1072.     'zSetAttr Status Value "Startar AmiTCP..."'
  1073.     address command
  1074.     'AmiTCP:bin/login -f 'prefs.username
  1075.     'AmiTCP:bin/umask 022'
  1076.     'AmiTCP:AmiTCP >NIL:'
  1077.     'SYS:Rexxc/WaitForPort AMITCP >NIL:'
  1078.     'AmiTCP:bin/ifconfig lo0 localhost'
  1079.     'AmiTCP:bin/ifconfig '||prefs.sanadriver||' '||left(slipip, length(slipip)-2)||' '||prefs.hostip||' netmask 255.255.255.0'
  1080.     'AmiTCP:bin/route add '||left(slipip, length(slipip)-2)||' localhost'
  1081.     'AmiTCP:bin/route add default '||prefs.gateway
  1082.     'echo >T:tcpmounter "Assign TCP: Exists >NIL:"'
  1083.     'echo >>T:tcpmounter "if warn"'
  1084.     'echo >>T:tcpmounter "mount TCP: from AmiTCP:devs/inet-mountlist"'
  1085.     'echo >>T:tcpmounter "endif"'
  1086.     'execute T:tcpmounter >NIL:'
  1087.     'run AmiTCP:bin/inetd >NIL:'
  1088.     address
  1089.     'zSetAttr Status Value "Uppkopplad mot 'prefs.hostname'!"'
  1090.     flags.tcponline = 1
  1091.     call GetHostName()
  1092.     return 0
  1093.  
  1094.  
  1095.